package com.pan.admin.module.api.controller;

import com.pan.admin.common.annotation.Log;
import com.pan.admin.common.core.controller.BaseController;
import com.pan.admin.common.core.domain.AjaxResult;
import com.pan.admin.common.core.page.TableDataInfo;
import com.pan.admin.common.enums.BusinessType;
import com.pan.admin.module.api.entity.ApiDataExchangeBacklist;
import com.pan.admin.module.api.service.ApiDataExchangeBacklistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * apiDataExchangeBacklistController
 *
 * @author ZJQ
 * @date 2024-10-25
 */
@RestController
@RequestMapping("/api/apiDataExchangeBacklist")
public class ApiDataExchangeBacklistController extends BaseController {

    @Autowired
    private ApiDataExchangeBacklistService apiDataExchangeBacklistService;

    /**
     * 查询撞库黑名单数据列表
     */
    @PreAuthorize("@ss.hasPermi('api:apiDataExchangeBacklist:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApiDataExchangeBacklist apiDataExchangeBacklist) {
        startPage();
        List<ApiDataExchangeBacklist> list = apiDataExchangeBacklistService.list(apiDataExchangeBacklist);
        return getDataTable(list);
    }

    /**
     * 新增撞库黑名单数据
     */
    @PreAuthorize("@ss.hasPermi('api:apiDataExchangeBacklist:add')")
    @Log(title = "API撞库黑名单新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApiDataExchangeBacklist apiDataExchangeBacklist) {
        return toAjax(apiDataExchangeBacklistService.insetApiDataExchangeBacklist(apiDataExchangeBacklist));
    }

    /**
     * 删除撞库黑名单数据
     */
    @PreAuthorize("@ss.hasPermi('api:apiDataExchangeBacklist:remove')")
    @Log(title = "删除手机号", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return toAjax(apiDataExchangeBacklistService.deleteById(id));
    }

}
